package com.mall.auth;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class test {


    @Test
    public void merge() {
        int[] arr1 = new int[]{1,3,6,18};
        int[] arr2 = new int[]{2,4,8,10};
        int[] mergedArray = new int[arr1.length+arr2.length];

        int i=0;
        int j=0;
        int k=0;
        while (i<arr1.length&&j<arr2.length){
            if (arr1[i] < arr2[j]) {
                mergedArray[k++] = arr1[i++];
            } else {
                mergedArray[k++] = arr2[j++];
            }
        }

        if(i<arr1.length){
            mergedArray[k++] = arr1[i++];
        }
        if(j<arr2.length){
            mergedArray[k++] = arr2[j++];
        }
        for (int i1 : mergedArray) {
            System.out.print(i1 + " ");
        }
    }
}
